package dao.impl;

import dao.Action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;

public class ActionLoginImpl implements Action {
    /**
     * 执行方法
     *
     * @param request
     * @param response
     * @throws Exception
     */
    @Override
    public void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
        request.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        String username = request.getParameter("username");
        String password = request.getParameter("password");

        if (username.equals("admin") && password.equals("123456")) {
            request.getSession().setAttribute("username", username);
            out.print("ok");
        }
        out.flush();
        out.close();
    }
}
